/**
 * 功能描述
 */
define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	var procDestnBuilding = require("../store/procDestnBuilding");
    var instance = {
        initComponent: function (params,widget) {
        	var subnav = new Subnav({
        		parentNode:".J-subnav",
        		model:{
        			title:"楼宇所属目的地",
        			items:[{
        				id:"search",
        				type:"search",
        				placeholder:"名称",
        				handler : function(str){
        					var grid = widget.get("grid");
        					aw.ajax({
        						url:"api/destnbuilding/search*",
        						data:{
        							s:str,
        							properties:"orgBuilding.name",
        							fetchProperties:procDestnBuilding.fetchProperties
        						},
        						dataType:"json",
        						success:function(data){
        							grid.setData(data);
        						}
        					});
        				}
        			},{
        				id:"servicePoint",
        				type:"buttongroup",
        				all:{
        					show:false,
        					first:true
        				},
        				tip:"服务点",
        				//show:true,
        				lazy:true,
        				keyField :"pkServicePoint",
						valueField :"name",
						params: function(){
							return{
								fetchProperties:"pkServicePoint,name"
							}
						},
						handler:function(key,element){
							widget.get("grid").refresh();
							/*var form = widget.get("form");
							form.load("orgBuilding",{
								params:{
									"servicePoint":widget.get("subnav").getValue("servicePoint"),
									fetchProperties:"pkOrgBuilding,name,floors,roomCount," +
											"servicePoint.name,servicePoint.pkServicePoint," +
											"pkDestination,name"
								},callback:function(data){
								}
							})*/
						}
        			},{
        				id : "add",
						type : "button",
						text:"新增",		
						handler:function(){
							widget.get("grid").refresh();
							widget.get("form").reset();
							widget.show([".J-form"]).hide([".J-grid"]);
							widget.get("subnav").hide(["search","add","servicePoint"]).show(["return"]);
						}
        			},{
        				id : "return",
						type : "button",
						text:"返回",						
						show : false,
						handler:function(){
							widget.show([".J-grid"]).hide([".J-form"]);
							widget.get("subnav").hide(["return"]).show(["search","add","servicePoint"]);
							widget.get("grid").refresh();
							widget.get("form").reset();
						}
        			}]
        	
        		}
        	});
        	widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});


    
